<?php 
/**
 * 会员控制器
 */
class Member extends Admin_Controller
{
	
	function __construct(){
		parent::__construct();

		$this->load->model('Admin/Member_model', 'member');
	}

	/**
	 * [会员列表]
	 * @Author   zt
	 * @DateTime 2018-08-03
	 * @param    [type]     $page [页码]
	 */
	function memberList($page = 1)
	{
		if ($_GET) {
			$get = $this->input->get();
		} else {
			$get = array();
		}

		$data = $this->member->memberList($page, $get);

		$data['page'] = $page;	// 当前页码
		$data['start'] = ($page - 1) * LINES + 1;	// 当前页起始条数

		// 当前页截止条数
		if ($page * LINES >= $data['count']) {
			$data['end'] = $data['count'];
		} else {
			$data['end'] = $page * LINES;
		}
		
		// 获取筛选条件
		$data['get'] = $_SERVER['QUERY_STRING'];

		// 每页显示条数
		$data['line'] = LINES;

		// 页面跳转链接
		$data['url'] = base_url().'Admin/Member/memberList/';
		$this->load->view('Admin/Member/MemberList', $data);
	}

	/**
	 * [获取会员详情]
	 * @Author   zt
	 * @DateTime 2018-08-03
	 * @param    [type]     $id [会员id]
	 */
	function memberDetail($id)
	{
		$data = $this->member->memberDetail($id);

		$this->load->view('Admin/Member/MemberDetail', $data);
	}

	/**
	 * [标记会员是否为海宝]
	 * @Author   zt
	 * @DateTime 2018-08-03
	 * @param    [type]     $id   [会员id]
	 * @param    [type]     $type [0否1是]
	 * @return   [type]           [description]
	 */
	function signType($id, $type)
	{
		$res = $this->member->signType($id, $type);
		if ($res['code'] == 1) {
			$this->success($res['msg']);
		} else {
			$this->error($res['msg']);
		}
	}

	/**
	 * [ajax获取新会员人数]
	 * @Author   zt
	 * @DateTime 2018-08-22
	 * @return   [type]     [description]
	 */
	function ajaxGetNewMember()
	{
		$echo = $this->member->ajaxGetNewMember();

		echo json_encode($echo);
	}

	/**
	 * [修改新会员标记]
	 * @Author   zt
	 * @DateTime 2018-08-22
	 * @return   [type]     [description]
	 */
	function ajaxEditNewMember()
	{
		$echo = $this->member->ajaxEditNewMember();

		echo json_encode($echo);
	}
}